package com.golxen.framework.common.server.game.dao.entity;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

public class ProcessInfo {
	private int serverId;

	private String serverName;

	private int serverIndex;

	private String name;

	private String address;

	private int port;

	private int adminPort;

	public int getServerId() {
		return serverId;
	}

	public void setServerId(int serverId) {
		this.serverId = serverId;
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public int getServerIndex() {
		return serverIndex;
	}

	public void setServerIndex(int serverIndex) {
		this.serverIndex = serverIndex;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public int getAdminPort() {
		return adminPort;
	}

	public void setAdminPort(int adminPort) {
		this.adminPort = adminPort;
	}

	public static ProcessInfo parsingProcessInfo(String infoStr, int serverId) {
		if (StringUtils.isBlank(infoStr)) {
			return null;
		}
		ProcessInfo info = new ProcessInfo();
		info.setServerId(serverId);

		JSONObject jObject = JSONObject.parseObject(infoStr);
		info.setServerName(jObject.getString("serverName"));
		info.setServerIndex(jObject.getIntValue("serverIndex"));
		info.setName(jObject.getString("name"));
		info.setAddress(jObject.getString("address"));
		info.setPort(jObject.getIntValue("port"));
		info.setAdminPort(jObject.getIntValue("adminPort"));
		return info;

	}

}
